import matplotlib.pyplot as plt
# 手动从日志中填入每个 epoch 的值
epochs = list(range(15))
losses = [
    1647.967, 1448.338, 1311.169, 1197.116, 1101.703,
    1007.975, 921.664, 853.079, 796.498, 748.645,
    714.992, 679.169, 652.630, 629.841, 610.918
]
accuracies = [
    9.33, 14.31, 16.41, 23.26, 29.13,
    32.01, 34.37, 40.34, 42.31, 42.79,
    41.77, 47.87, 44.34, 46.15, 48.58
]
plt.figure(figsize=(12, 5))

# 子图1：Loss 曲线
plt.subplot(1, 2, 1)
plt.plot(epochs, losses, marker='o', color='red', label='Train Loss')
plt.title('Training Loss over Epochs')
plt.xlabel('Epoch')
plt.ylabel('Loss')
plt.grid(True)
plt.legend()

# 子图2：Accuracy 曲线
plt.subplot(1, 2, 2)
plt.plot(epochs, accuracies, marker='s', color='blue', label='Test Accuracy')
plt.title('Test Accuracy over Epochs')
plt.xlabel('Epoch')
plt.ylabel('Accuracy (%)')
plt.grid(True)
plt.legend()

plt.tight_layout()
plt.savefig('training_results.png', dpi=300)
plt.show()
